package com.an.makedata;

import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.swing.plaf.synth.SynthScrollBarUI;

import org.apache.commons.codec.binary.StringUtils;

import com.fasterxml.jackson.databind.ObjectMapper;

import redis.clients.jedis.Jedis;

/**
 * ClassName: ToMakePhonenumberX <br/>
 * Function: TODO 功能描述. <br/>
 * Reason: TODO 编写原因. <br/>
 * date: 2017年11月28日 下午6:32:53 <br/>
 *
 * @author atc
 * @version 1.0.0
 * @since JDK 1.8
 */
public class ToMakePhonenumberX {

	/**
	 * main:这里用一句话描述这个方法的作用. <br/>
	 * TODO这里描述这个方法适用条件 – 可选.<br/>
	 *
	 * @author atc
	 * @param args
	 * @since JDK 1.8
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		Jedis jedis = new Jedis("10.8.29.57");
		jedis.auth("AS@redis");
		jedis.hset(Key.getAxbUserwhiteListKey("13355667788"), "phoneNumberA", "17252770002");
		jedis.hset(Key.getAxbUserwhiteListKey("13355667788"), "whiteList", "1330681,13306811709,13966623928");

		System.out.println(jedis.hgetAll(Key.getAxbUserwhiteListKey("13355667788")));
		/*ToMakePhonenumberX tMakePhonenumberX = new ToMakePhonenumberX();
		for(int i=30;i<40;i++) {
			tMakePhonenumberX.productX("130012301"+i, "571", null, jedis);
			System.out.println("-----------");
		}*/
		jedis.close();

	}
	
	/**
	 * 
	 * productX:生成号码，存入redis.<br/>
	 *
	 * @author atc
	 * @param num
	 * @since JDK 1.8
	 */
	@SuppressWarnings("unchecked")
	public void productX(String num,String areaCode,String customerId,Jedis jedis) {
		PhoneNumber phoneNumber = new PhoneNumber();
		phoneNumber.setAreaCode(areaCode);
		phoneNumber.setPhoneNumber(num);
		phoneNumber.setPhoneNumberType(PhoneNumber.PHONE_NUMBER_TYPE_X);
		phoneNumber.setServiceCode(PhoneNumber.SERVICE_CODE_AXB);
		phoneNumber.setProvinceCode("zj");
		phoneNumber.setCustomerId(customerId == null?"":customerId);
		phoneNumber.setImsi(PhoneNumber.DEFAULT_PARAMETER);
		phoneNumber.setSmsCenterNumber(PhoneNumber.DEFAULT_PARAMETER);

		ObjectMapper objectMapper = new ObjectMapper();
		Map<String, String> map = null;
		try {
			map = objectMapper.readValue(objectMapper.writeValueAsString(phoneNumber), Map.class);
		} catch (IOException e) {
			e.printStackTrace();
		}
		map.remove("axbBindingPhoneNumberMap");
		map.remove("binding");
		System.out.println(map);
		System.out.println("key:" + Key.getPhoneNumberKey(num));
		jedis.hmset(Key.getPhoneNumberKey(num), map);

	/*	jedis.hsetnx(Key.getCustomerPhoneNumberKey(PhoneNumber.NO_CUSTOMER_ID_DEFAULT), num,
				PhoneNumber.PHONE_NUMBER_TYPE_X);*/
		System.out.println("key-->" + Key.getCustomerPhoneNumberKey("86af8f8215b54dac8641e72dd226ab5f"));
	}

}
